Uncompressed RGB
Uncompressed RGB data is stored in a variety of different formats. The format used depends on the Depth field of the video sample description. For all depths, the image data is padded on each scan line to ensure that each scan line begins on an even byte boundary.
-
For depths of 1, 2, 4, and 8, the values stored are indexes into the color table specified in the Color table id field.
-
For a depth of 16, the pixels are stored as 5-5-5 RGB values with the high bit of each 16-bit integer set to 0.
-
For a depth of 24, the pixels are stored packed together in RGB order.
-
For a depth of 32, the pixels are stored with an 8-bit alpha channel, followed by 8-bit RGB components.
Motion JPEG
Motion JPEG (M-JPEG) is a variant of the ISO JPEG specification for use with digital video streams. Instead of compressing an entire image into a single bitstream, M-JPEG compresses each video field separately, returning the resulting JPEG bitstreams consecutively in a single frame.
There are two flavors of M-JPEG currently in use. These two formats differ based on their use of markers. M-JPEG format A supports markers; M-JPEG format B does not. The following paragraphs describe how QuickTime stores M-JPEG sample data.
Each field of M-JPEG Format A fully complies with the ISO JPEG specification, and therefore supports application markers. QuickTime uses the app 1 marker to store control information, as follows (all of the fields are 32-bit integers):
-
Reserved
-
Contents unpredictable; should be set to 0.
-
Tag
-
Identifies the data type; this field must be set to
'mjpg'
.
-
Field size
-
Contains the actual size of the image data for this field, in bytes.
-
Padded field size
-
Contains the size of the image data, including pad bytes. Some video hardware may append pad bytes to the image data; this field, along with the Field size field, allows you to compute how many pad bytes were added.
-
Offset to next field
-
Specifies the offset, in bytes, from the start of the field data to the start of the next field in the bitstream. This field should be set to 0 in the second field's marker data.
-
Quantization table offset
-
Specifies the offset, in bytes, from the start of the field data to the quantization table marker. If this field is set to 0, check the image description for a default quantization table (see
"Video Sample Description"
for details).
-
Huffman table offset
-
Specifies the offset, in bytes, from the start of the field data to the Huffman table marker. If this field is set to 0, check the image description for a default Huffman table (see
"Video Sample Description"
for details).
-
Start of image offset
-
Specifies the offset from the start of the field data to the start of image marker. This field should never be set to 0.
M-JPEG Format B does not support markers. In place of the marker, therefore, QuickTime inserts a header at the beginning of the bitstream. Again, all of the fields are 32-bit integers.
-
Reserved
-
Contents unpredictable; should be set to 0.
-
Tag
-
Identifies the data type; this field must be set to
'mjpg'
.
-
Field size
-
Contains the actual size of the image data for this field, in bytes.
-
Padded field size
-
Contains the size of the image data, including pad bytes. Some video hardware may append pad bytes to the image data; this field, along with the Field size field, allows you to compute how many pad bytes were added.
-
Offset to next field
-
Specifies the offset, in bytes, from the start of the field data to the start of the next field in the bitstream. This field should be set to 0 in the second field's header data.
-
Quantization table offset
-
Specifies the offset, in bytes, from the start of the field data to the quantization table. If this field is set to 0, check the image description for a default quantization table (see
"Video Sample Description"
for details).
-
Huffman table offset
-
Specifies the offset, in bytes, from the start of the field data to the Huffman table. If this field is set to 0, check the image description for a default Huffman table (see
"Video Sample Description"
for details).
-
Start of image offset
-
Specifies the offset from the start of the field data to the field's image data. This field should never be set to 0.
-
Reserved
-
Must be set to 0.
-
Reserved
-
Must be set to 0.
The M-JPEG Format B header must be a multiple of 16 in size. When you add pad bytes to the header, set them to 0.
Because this format does not support markers, there is no need to stuff the bitstream with null bytes (0x00) after data bytes that are set to 0xFF.